package com.cooper.mediadb;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.cooper.android.comm.Resource;

public abstract class Media implements Resource, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3513994563301818563L;	

	public final static int DETAILS_IS_OK = 0;
	public final static int DETAILS_IS_FAIL = 1;

	public static float HEIGHT_WIDHT_SCALE = 0.68f;

	protected String id;
	protected String genre;
	protected String title;
	private String director;
	private String plot;

	private String imdbId;
	private String originaltitle;
	private String year = null;
	private String runtime;
	private String studio;
	private String outline;
	private String votes;
	private String tagline;
	private String mpaa;
	private String credits;
	private String trailer;
	private String country;
	private String overview;
	private Date joinTime;
	private String rating;
	private String releasedDate = null;
	
	public Media(){
		super();
	}

	public Media(String id, String genre, String title, String director,
			String plot, String imdbId, String originaltitle, String year,
			String runtime, String studio, String outline, String votes,
			String tagline, String mpaa, String credits, String trailer,
			String country, String overview, Date joinTime, String rating) {
		super();
		this.id = id;
		this.genre = genre;
		this.title = title;
		this.director = director;
		this.plot = plot;
		this.imdbId = imdbId;
		this.originaltitle = originaltitle;
		this.year = year;
		this.runtime = runtime;
		this.studio = studio;
		this.outline = outline;
		this.votes = votes;
		this.tagline = tagline;
		this.mpaa = mpaa;
		this.credits = credits;
		this.trailer = trailer;
		this.country = country;
		this.overview = overview;
		this.joinTime = joinTime;
		this.rating = rating;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getDirector() {
		return director;
	}

	public void setDirector(String director) {
		this.director = director;
	}

	public String getGenre() {
		return genre;
	}

	public void setGenre(String genre) {
		this.genre = genre;
	}

	public String getPlot() {
		return plot;
	}

	public void setPlot(String plot) {
		this.plot = plot;
	}

	@Override
	public String getSubtitle() {
		return getGenre();
	}

	@Override
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getImdbId() {
		return imdbId;
	}

	public void setImdbId(String imdbId) {
		this.imdbId = imdbId;
	}

	public String getOriginaltitle() {
		return originaltitle;
	}

	public void setOriginaltitle(String originaltitle) {
		this.originaltitle = originaltitle;
	}

	public String getYear() {
		if ((year == null) && (releasedDate != null)) {
			try {
				return String.valueOf(new Date(Date.parse(releasedDate))
						.getYear() + 1900);
			} catch (Exception e) {
				return year;
			}
		}
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}

	public String getRuntime() {
		return runtime;
	}

	public void setRuntime(String runtime) {
		this.runtime = runtime;
	}

	public String getStudio() {
		return studio;
	}

	public void setStudio(String studio) {
		this.studio = studio;
	}

	public String getOutline() {
		return outline;
	}

	public void setOutline(String outline) {
		this.outline = outline;
	}

	public String getVotes() {
		return votes;
	}

	public void setVotes(String votes) {
		this.votes = votes;
	}

	public String getTagline() {
		return tagline;
	}

	public void setTagline(String tagline) {
		this.tagline = tagline;
	}

	public String getMpaa() {
		return mpaa;
	}

	public void setMpaa(String mpaa) {
		this.mpaa = mpaa;
	}

	public String getCredits() {
		return credits;
	}

	public void setCredits(String credits) {
		this.credits = credits;
	}

	public String getTrailer() {
		return trailer;
	}

	public void setTrailer(String trailer) {
		this.trailer = trailer;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getOverview() {
		return overview;
	}

	public void setOverview(String overview) {
		this.overview = overview;
	}

	public String getRating() {
		return rating;
	}

	public void setRating(String rating) {
		this.rating = rating;
	}

	public Date getJoinTime() {
		return joinTime;
	}

	public void setJoinTime(Date joinTime) {
		this.joinTime = joinTime;
	}

	@Override
	public boolean equals(Object object) {
		if (object == null) {
			return false;
		}
		if (this == object) {
			return true;
		}
		if (object instanceof Media) {
			return ((Media) object).getId().equals(this.id);
		} else
			return false;
	}

	@Override
	public int hashCode() {
		return getId().hashCode();
	}

	public abstract List<Actor> getActors();

	public String getReleasedDate() {
		if ((releasedDate == null) && (year != null)) {
			return year;
		}
		return releasedDate;
	}

	public void setReleasedDate(String releasedDate) {
		
		this.releasedDate = releasedDate;
	}

}
